﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GioHang.aspx.cs" Inherits="ThoiTrangT2B.GioHang"
    MasterPageFile="~/TwoColumn.Master" EnableEventValidation="true" %>

<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
    <link rel="stylesheet" type="text/css" href="css/component.css" />

    <script type="text/javascript">
        $(document).ready(function() {
        var num = 0;
        $("#<%=grvGioHang.ClientID %> tr").each(function() {
            //Skip first(header) row
            if (!this.rowIndex) return;
            var age = $(this).find("td:last span").html();
            num += parseFloat(age.replace(',', '').replace(',', ''));
        });
        $("#<%=listAge.ClientID %>").html(num.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,"))
        });
        function CalcSellPrice2(CurPr, txtSL, lblTongCong) {
            var SL = parseFloat(document.getElementById(txtSL).value);
            var txtTongCong = document.getElementById(lblTongCong);
            var SellPriceValue = parseFloat(CurPr * SL);
            SellPriceValue = SellPriceValue.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,");
            txtTongCong.innerHTML = SellPriceValue;

            var num = 0;
            $("#<%=grvGioHang.ClientID %> tr").each(function() {
                //Skip first(header) row
                if (!this.rowIndex) return;
                var age = $(this).find("td:last span").html();
                num += parseFloat(age.replace(',', '').replace(',', ''));
            });
            $("#<%=listAge.ClientID %>").html(num.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,"))
        }
    </script>

    <script src="css/modernizr.custom.js"></script>

    <div class="DetailBlock" style="width: 100%">
        <h2 class="GioHangTitle">
            &nbsp;&nbsp;&nbsp;Giỏ hàng</h2>
        <asp:GridView ID="grvGioHang" runat="server" AutoGenerateColumns="False" DataKeyNames="ID"
            CssClass="tblGioHang" OnRowDataBound="grvGioHang_RowDataBound" OnRowCommand="grvGioHang_RowCommand">
            <Columns>
                <asp:TemplateField HeaderText="Xóa">
                    <ItemTemplate>
                        <asp:ImageButton ID="imgDelete" runat="server" ImageUrl="../images/cart-delete.png"
                            ToolTip="Xóa" CommandArgument='<%# Eval("ID")%>' CommandName="<%# ThoiTrangT2B.MyConst.Action.Delete %>"
                            OnClientClick="return confirm('Bạn có chắc là muốn xóa sản phẩm này khỏi giỏ hàng không ?')">
                        </asp:ImageButton>
                    </ItemTemplate>
                    <ItemStyle Width="70px"></ItemStyle>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Sản phẩm">
                    <ItemTemplate>
                        <asp:Image ID="imgAnhSP" CssClass="ImgSanPhamGioHang" ImageUrl='<%# Eval("Image") %>'
                            runat="server" />
                        <%# Eval("TenSP").ToString()%>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Giá">
                    <ItemTemplate>
                        <asp:Label ID="lblGia" CssClass="priceBold" runat="server" Text='<%# Bind("GiaCu", "{0:###,###}")  %>'></asp:Label>&nbsp;VNĐ
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Số lượng">
                    <ItemTemplate>
                        <asp:TextBox ID="txtSL" CssClass="SoLuong" runat="server">1</asp:TextBox>
                        Chiếc
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Tổng cộng">
                    <ItemTemplate>
                        <asp:Label ID="lblTongCong" CssClass="priceBold TotalBox" runat="server" Text='<%# Bind("GiaCu", "{0:###,###}")  %>'></asp:Label>&nbsp;VNĐ
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <p class="ThanhTien">
            Thành tiền : <span id="listAge" runat="server" class="priceBold"></span> &nbsp;VNĐ</p>
        <div class="steps-to-steps">
            <asp:LinkButton ID="lblBack" runat="server" CssClass="back-to-shop" OnClick="lblBack_Click">Tiếp tục mua hàng</asp:LinkButton>
            <asp:LinkButton ID="lbtThanhToan" runat="server" CssClass="goto-step" OnClick="lbtThanhToan_Click">Đặt hàng</asp:LinkButton>
        </div>
    </div>
</asp:Content>
